package main

import "fmt"

func InsertSort(arr *[5]int) {
	for i := 1; i < len(arr); i++ {
		insertVal := arr[i]
		insertIndex := i - 1
		//大->小
		for insertIndex >= 0 && arr[insertIndex] < insertVal {
			arr[insertIndex+1] = arr[insertIndex]
			insertIndex--
		}
		if insertIndex+1 != i {
			arr[insertIndex+1] = insertVal
		}

	}
}

func main() {
	arr := [5]int{10, 34, 19, 100, 80}
	fmt.Println("排序前", arr)
	InsertSort(&arr)
	fmt.Println("排序后", arr)

}
